package simonxianyu.learn.springmybatis.web;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * Created by simon on 2017/2/20.
 */
@Controller
public class IndexCtl {

  @RequestMapping("/")
  public String index(HttpServletRequest req) {
    if (StringUtils.containsIgnoreCase(req.getHeader("User-Agent"), "idea")) {
      return "ok";
    }
    if (req.getSession().getAttribute("smUser") == null) {
      return "redirect:/login";
    }
    return "dashboard";
  }

  @RequestMapping("/dashboard")
  public String dashboard() {
    return "dashboard";
  }

}
